package com.webster.isw.core.service;

import com.webster.isw.core.exception.SystemException;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.quartz.Trigger;

/**
 * 触发器监听服务
 * Created by Webster on 16/5/8.
 */
public interface TriggerService extends BaseService {
    /**
     * Description: 保存未正常触发的记录
     */
    void saveErrorTrigger(Trigger trigger);

    /**
     * Description: 准备触发
     */
    void saveFiredTrigger(JobExecutionContext context) throws SystemException;

    /**
     * Description: 判断是否否决
     */
    boolean isJobVetoed(JobExecutionContext context) throws SystemException;

    /**
     * Description: 准备执行作业
     */
    void saveIntentStartJob(JobExecutionContext context) throws SystemException;

    /**
     * Description: 作业执行被否决
     */
    void saveVetoedJob(JobExecutionContext context) throws SystemException;

    /**
     * Description: 作业执行完毕
     */
    void saveCompletedJob(JobExecutionContext context, JobExecutionException jobException)
            throws SchedulerException;

    /**
     * Description: 触发完成
     */
    @SuppressWarnings("unchecked")
    void saveCompletedTrigger(JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
            throws SystemException;
}
